home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2167 < prev    next >
Encoding:
Text File  |  1996-08-06  |  799 b   |  27 lines

  1. Path: news.production.compuserve.com!news
  2. From: Holger Maier <100336.3326@CompuServe.COM>
  3. Newsgroups: comp.lang.c++
  4. Subject: Q:order of evaluation
  5. Date: 16 Jan 1996 06:47:26 GMT
  6. Organization: DLZ Heidelberg
  7. Message-ID: <4dfhlu$a33$1@mhafn.production.compuserve.com>
  8.  
  9. Consider
  10. #include <iostream>
  11. int main() {
  12.   int i=1;int j=i+(i+=1);
  13.   cout<<i<<','<<j<<'\n';
  14.   return 0;
  15. }
  16. on my compiler this produces 2,4
  17. Looked up the ARM:
  18. 5: .. The order of evaluation of subexpressions is determined by the
  19. precedence and grouping of operators.
  20. 5.7: The additive operators + and - group left to right.
  21. So, j should be assigned 3 ??
  22. Now the question to you C++ gurus out there on the nets:
  23. Is it really a compiler bug or is it just me misinterpreting the 
  24. ARM?
  25. BTW: I know we should not code like that...
  26. Holger
  27.